<?php namespace Home\Controller; 
use Hdphp\Controller\Controller;
class CommonController extends Controller{
	
	
	public function __construct(){
	
		$cartdata = Cart::getGoods(); 
		$id = Cart::getOrderId();
		$sum = Cart::getTotalPrice();
		if(isset($cartdata)){
			
		
		foreach ($cartdata as $k => $v) {
			$cartdata[$k]['g_pic'] = Db::table("360mall_goods")->where("g_id",$v['id'])->pluck('g_pic');
		$cartdata[$k]['sum']=$sum;	
		$cartdata[$k]['total_rows']= $_SESSION['cart']['total_rows'];
		 }
		}
		View::with("cartdata",$cartdata);
	
	}
	//注册
  //删除购物车中的某一条数据数据
  public function delCart(){
  	if(IS_AJAX){
           $num = 0;
		   $gsid = $_POST['gsid'];
		   $data = array(
			   "sid"=>$gsid,
			   "num"=>$num,
			); 
      Cart::update($data); 

$datas['total'] = $_SESSION['cart']['total'];
$datas['total_rows']= $_SESSION['cart']['total_rows'];
echo json_encode($datas);
  }
  }
	
}
